#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
/*
https://blog.csdn.net/ldm_666/article/details/118500810

*/
int main() {
    string s;
    int arr[5] = { 0,100,200,200,220 };
    cin >> s;
        int n = s.size();
        vector<vector<int>>dp(n, vector<int>(n, 0));
        for (int i = n - 2; i >= 0; i--)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (s[i] == s[j])
                    dp[i][j] = dp[i + 1][j - 1];
                else
                {
                    int dp1 = dp[i + 1][j] + arr[(s[i] - '0')];
                    int dp2 = dp[i][j - 1] + arr[(s[j] - '0')];
                    dp[i][j] = min(dp1, dp2);
                }
            }
        }
        cout << dp[0][n - 1];
    return 0;
}